package edu.hzit.data.controller;

import edu.hzit.data.entity.Expense;
import edu.hzit.data.service.ExpenseService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("expense")
public class ExpenseController{
    @Resource
    private ExpenseService expenseService;

    @RequestMapping("insert")
    private int insert(Expense expense) {
        return expenseService.insert(expense);
    }

    @RequestMapping("loadList")
    private List<Expense> loadList() {
        return expenseService.loadList();
    }

    @RequestMapping("selectById")
    private Expense selectById(int expenseId) {
        return expenseService.selectById(expenseId);
    }

    @RequestMapping("delete")
    private int delete(int expenseId) {
        return expenseService.delete(expenseId);
    }

    @RequestMapping("update")
    private int update(Expense expense) {
        return expenseService.update(expense);
    }

    @RequestMapping("sum")
    private int sum(Expense expense) {
        return expenseService.sum(expense);
    }

//    @RequestMapping("sumByMonth")
//    private int sumByMonth(@Param("userId")int userId, @Param("month") int month){
//        return expenseService.sumByMonth(userId,month);
//    }
}
